
clear all
set mem 1g
set more off


local path0="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\"
local path1="C:\Dropbox\GeneticsProject (1)\REStat\outregs"

cd "`path0'Data\IPUMS_2000"

use temp_census002, clear
gen lnage=(age)
gen lnage2=lnage^2

rename science_occupation so
rename science_occupationA soA
rename science_sector ss

gen e1_GBR=e_GBR
drop e_GBR

foreach mm in so {

*================================================================
*** control for basic exo vars + level of education for US-born
*** WEIGHTED
*================================================================

xi: reg  `mm' e_* lnage lnage2 i.educd [pw=perwt]  

gen coef1w_`mm'=0 if countrycode=="GBR"
gen se1w_`mm'=0 if countrycode=="GBR"

quiet foreach var in ///
		AGO ALB  ARE ARG AUS AUT BEL BFA BGD BGR BRA BTN CAN ///
		CHE CHL CHN COL CRI CZE DNK DOM ECU EGY ESP EST ETH FIN ///
		FJI FRA GER GHA GRC GTM HND HRV HUN IDN IND IRL IRN ///
		IRQ ISL ISR ITA JAM JOR JPN KEN KOR KWT LBN LBY LKA LTU LUX ///
		LVA MAR MEX MLT MOZ MWI MYS NAM NGA NLD NOR NPL NZL PAK PAN ///
		PER PHL POL PRT ROM RUS SAU SCG SEN SLE SLV SVK SVN SWE ///
		SYR THA TTO TUR TWN TZA UKR URY VEN VNM ZAF ZMB  ///
		{
		
capture replace coef1w_`mm'=_b[e_`var'] if countrycode=="`var'" & e(sample)
capture replace se1w_`mm'=_se[e_`var'] if countrycode=="`var'" & e(sample)

}

gen count1w_`mm'=coef1w_`mm'



*====================================================================
* 		Only persons with Bachalor and higher degree
*		WEIGHTED
*====================================================================
xi: reg  `mm' e_*   lnage lnage2 i.educd [pw=perwt]  if educd>=101

gen coef3w_`mm'=0 if countrycode=="GBR"
gen se3w_`mm'=0 if countrycode=="GBR"

quiet foreach var in ///
		AGO ALB  ARE ARG AUS AUT BEL BFA BGD BGR BRA BTN CAN ///
		CHE CHL CHN COL CRI CZE DNK DOM ECU EGY ESP EST ETH FIN ///
		FJI FRA GER GHA GRC GTM HND HRV HUN IDN IND IRL IRN ///
		IRQ ISL ISR ITA JAM JOR JPN KEN KOR KWT LBN LBY LKA LTU LUX ///
		LVA MAR MEX MLT MOZ MWI MYS NAM NGA NLD NOR NPL NZL PAK PAN ///
		PER PHL POL PRT ROM RUS SAU SCG SEN SLE SLV SVK SVN SWE ///
		SYR THA TTO TUR TWN TZA UKR URY VEN VNM ZAF ZMB  ///
		{
		
capture replace coef3w_`mm'=_b[e_`var'] if countrycode=="`var'" & e(sample)
capture replace se3w_`mm'=_se[e_`var'] if countrycode=="`var'" & e(sample)

}

gen count3w_`mm'=coef3w_`mm'
}

collapse (mean) idv coef* se* (count) count*_*, by(countrycode)
save research_career_propensity_all, replace

